function setup_global( sampling_rate);

global Downsample InIIR_Hsos InIIR_Nsos Align_Nfft
global DATAPADDING_MSECS SEARCHBUFFER Fs MINSPEECHLGTH JOINSPEECHLGTH

global Nutterances Largest_uttsize Nsurf_samples Crude_DelayEst
global Crude_DelayConf UttSearch_Start UttSearch_End Utt_DelayEst
global Utt_Delay Utt_DelayConf Utt_Start Utt_End
global MAXNUTTERANCES WHOLE_SIGNAL
global pesq_mos subj_mos cond_nr MINUTTLENGTH
global CALIBRATE Nfmax Nb Sl Sp 
global nr_of_hz_bands_per_bark_band centre_of_band_bark 
global width_of_band_hz centre_of_band_hz width_of_band_bark 
global pow_dens_correction_factor abs_thresh_power

CALIBRATE= 0;
Nfmax= 512;

MAXNUTTERANCES= 50;
MINUTTLENGTH= 50;
WHOLE_SIGNAL= -1;
UttSearch_Star= zeros( 1, MAXNUTTERANCES);
UttSearch_End= zeros( 1, MAXNUTTERANCES);
Utt_DelayEst= zeros( 1, MAXNUTTERANCES);
Utt_Delay= zeros( 1, MAXNUTTERANCES);
Utt_DelayConf= zeros( 1, MAXNUTTERANCES);
Utt_Start= zeros( 1, MAXNUTTERANCES);
Utt_End= zeros( 1, MAXNUTTERANCES);

DATAPADDING_MSECS= 320;
SEARCHBUFFER= 75;
MINSPEECHLGTH= 4;
JOINSPEECHLGTH= 50;

Sp_16k = 6.910853e-006;
Sl_16k = 1.866055e-001;
fs_16k= 16000;
Downsample_16k = 64;
Align_Nfft_16k = 1024;
InIIR_Nsos_16k = 12;
InIIR_Hsos_16k = [
   0.325631521,        -0.086782860,  -0.238848661,  -1.079416490,  0.434583902;
   0.403961804,        -0.556985881,  0.153024077,   -0.415115835,  0.696590244;
   4.736162769,        3.287251046,   1.753289019,   -1.859599046,  0.876284034;
   0.365373469,        0.000000000,   0.000000000,   -0.634626531,  0.000000000;
   0.884811506,        0.000000000,   0.000000000,   -0.256725271,  0.141536777;
   0.723593055,        -1.447186099,  0.723593044,   -1.129587469,  0.657232737;
   1.644910855,        -1.817280902,  1.249658063,   -1.778403899,  0.801724355;
   0.633692689,        -0.284644314,  -0.319789663,  0.000000000,   0.000000000;
   1.032763031,        0.268428979,   0.602913323,   0.000000000,   0.000000000;
   1.001616361,        -0.823749013,  0.439731942,   -0.885778255,  0.000000000;
   0.752472096,        -0.375388990,  0.188977609,   -0.077258216,  0.247230734;
   1.023700575,        0.001661628,   0.521284240,   -0.183867259,  0.354324187
   ];

Sp_8k = 2.764344e-5;
Sl_8k = 1.866055e-1;
fs_8k= 8000;
Downsample_8k = 32;
Align_Nfft_8k = 512;
InIIR_Nsos_8k = 8;
InIIR_Hsos_8k = [
    0.885535424,       -0.885535424,  0.000000000,   -0.771070709,  0.000000000;
    0.895092588,       1.292907193,   0.449260174,   1.268869037,   0.442025372;
    4.049527940,       -7.865190042,  3.815662102,   -1.746859852,  0.786305963;
    0.500002353,       -0.500002353,  0.000000000,   0.000000000,   0.000000000;
    0.565002834,       -0.241585934,  -0.306009671,  0.259688659,   0.249979657;
    2.115237288,       0.919935084,   1.141240051,   -1.587313419,  0.665935315;
    0.912224584,       -0.224397719,  -0.641121413,  -0.246029464,  -0.556720590;
    0.444617727,       -0.307589321,  0.141638062,   -0.996391149,  0.502251622
    ];

nr_of_hz_bands_per_bark_band_8k = [
    1,    1,    1,    1,    1,     1,    1,    1,    2,    1, ...
    1,    1,    1,    1,    2,     1,    1,    2,    2,    2, ...
    2,    2,    2,    2,    2,     3,    3,    3,    3,    4, ...
    3,    4,    5,    4,    5,     6,    6,    7,    8,    9, ...
    9,    11
    ];

centre_of_band_bark_8k = [
    0.078672,   0.316341,   0.636559,   0.961246,   1.290450, ...
    1.624217,   1.962597,   2.305636,   2.653383,   3.005889, ...
    3.363201,   3.725371,   4.092449,   4.464486,   4.841533, ...
    5.223642,   5.610866,   6.003256,   6.400869,   6.803755, ...
    7.211971,   7.625571,   8.044611,   8.469146,   8.899232, ...
    9.334927,   9.776288,   10.223374,  10.676242,  11.134952,...
    11.599563,  12.070135,  12.546731,  13.029408,  13.518232,...
    14.013264,  14.514566,  15.022202,  15.536238,  16.056736,...
    16.583761,  17.117382
    ];

centre_of_band_hz_8k = [
    7.867213,    31.634144,   63.655895,   96.124611,   129.044968,...
    162.421738,  196.259659,  230.563568,  265.338348,  300.588867,...     
    336.320129,  372.537140,  409.244934,  446.448578,  484.568604,...     
    526.600586,  570.303833,  619.423340,  672.121643,  728.525696,...     
    785.675964,  846.835693,  909.691650,  977.063293,  1049.861694,...     
    1129.635986, 1217.257568, 1312.109497, 1412.501465, 1517.999390,...   
    1628.894165, 1746.194336, 1871.568848, 2008.776123, 2158.979248,...     
    2326.743164, 2513.787109, 2722.488770, 2952.586670, 3205.835449,... 
    3492.679932, 3820.219238
    ];

width_of_band_bark_8k = [
    0.157344,     0.317994,     0.322441,     0.326934,     0.331474, ...    
    0.336061,     0.340697,     0.345381,     0.350114,     0.354897, ...    
    0.359729,     0.364611,     0.369544,     0.374529,     0.379565, ...    
    0.384653,     0.389794,     0.394989,     0.400236,     0.405538, ...    
    0.410894,     0.416306,     0.421773,     0.427297,     0.432877, ...    
    0.438514,     0.444209,     0.449962,     0.455774,     0.461645, ...    
    0.467577,     0.473569,     0.479621,     0.485736,     0.491912, ...    
    0.498151,     0.504454,     0.510819,     0.517250,     0.523745, ...    
    0.530308,     0.536934
    ];

width_of_band_hz_8k = [
    15.734426,  31.799433,  32.244064,   32.693359,   33.147385, ...    
    33.606140,  34.069702,  34.538116,   35.011429,   35.489655, ...    
    35.972870,  36.461121,  36.954407,   37.452911,   40.269653, ...    
    42.311859,  45.992554,  51.348511,   55.040527,   56.775208, ...    
    58.699402,  62.445862,  64.820923,   69.195374,   76.745667, ...   
    84.016235,  90.825684,  97.931152,   103.348877,  107.801880, ...    
    113.552246, 121.490601, 130.420410,  143.431763,  158.486816,  ...   
    176.872803, 198.314697, 219.549561,  240.600098,  268.702393,  ...   
    306.060059, 349.937012
    ];

pow_dens_correction_factor_8k = [
    100.000000,  99.999992,   100.000000,  100.000008,   100.000008,... 
    100.000015,  99.999992,   99.999969,   50.000027,    100.000000,...     
    99.999969,   100.000015,  99.999947,   100.000061,   53.047077, ...    
    110.000046,  117.991989,  65.000000,   68.760147,    69.999931, ...    
    71.428818,   75.000038,   76.843384,   80.968781,    88.646126, ...    
    63.864388,   68.155350,   72.547775,   75.584831,    58.379192,...     
    80.950836,   64.135651,   54.384785,   73.821884,    64.437073, ...    
    59.176456,   65.521278,   61.399822,   58.144047,    57.004543,...     
    64.126297,   59.248363
    ];

abs_thresh_power_8k = [
    51286152,     2454709.500,  70794.593750,  ...
    4897.788574,  1174.897705,  389.045166,  ...
    104.712860,   45.708820,    17.782795,   ...
    9.772372,     4.897789,     3.090296,     ...
    1.905461,     1.258925,     0.977237,     ...
    0.724436,     0.562341,     0.457088,     ...
    0.389045,     0.331131,     0.295121,     ...
    0.269153,     0.257040,     0.251189,     ...
    0.251189,     0.251189,     0.251189,     ...
    0.263027,     0.288403,     0.309030,     ...
    0.338844,     0.371535,     0.398107,     ...
    0.436516,     0.467735,     0.489779,     ...
    0.501187,     0.501187,     0.512861,     ...
    0.524807,     0.524807,     0.524807
    ];

nr_of_hz_bands_per_bark_band_16k = [
    1,    1,    1,    1,    1,   1,    1,    1,    2,    1,    ...
    1,    1,    1,    1,    2,   1,    1,    2,    2,    2,    ...
    2,    2,    2,    2,    2,   3,    3,    3,    3,    4,    ...
    3,    4,    5,    4,    5,   6,    6,    7,    8,    9,    ...
    9,    12,   12,   15,   16,  18,   21,   25,   20
    ];

centre_of_band_bark_16k = [
    0.078672,   0.316341,   0.636559,    0.961246,     1.290450, ...
    1.624217,   1.962597,   2.305636,    2.653383,     3.005889, ...
    3.363201,   3.725371,   4.092449,    4.464486,     4.841533, ...
    5.223642,   5.610866,   6.003256,    6.400869,     6.803755, ...
    7.211971,   7.625571,   8.044611,    8.469146,     8.899232, ...
    9.334927,   9.776288,   10.223374,   10.676242,    11.134952, ...
    11.599563,  12.070135,  12.546731,   13.029408,    13.518232, ...
    14.013264,  14.514566,  15.022202,   15.536238,    16.056736, ...
    16.583761,  17.117382,  17.657663,   18.204674,    18.758478, ...
    19.319147,  19.886751,  20.461355,   21.043034
    ];

centre_of_band_hz_16k = [
    7.867213,     31.634144,    63.655895,    96.124611,   129.044968,...
    162.421738,   196.259659,   230.563568,   265.338348,  300.588867,...
    336.320129,   372.537140,   409.244934,   446.448578,  484.568604,...
    526.600586,   570.303833,   619.423340,   672.121643,  728.525696,...
    785.675964,   846.835693,   909.691650,   977.063293,  1049.861694,...
    1129.635986,  1217.257568,  1312.109497,  1412.501465, 1517.999390,...
    1628.894165,  1746.194336,  1871.568848,  2008.776123, 2158.979248,...
    2326.743164,  2513.787109,  2722.488770,  2952.586670, 3205.835449,...
    3492.679932,  3820.219238,  4193.938477,  4619.846191, 5100.437012,...
    5636.199219,  6234.313477,  6946.734863,  7796.473633
    ];

width_of_band_bark_16k = [
    0.157344,     0.317994,     0.322441,     0.326934,     0.331474,...
    0.336061,     0.340697,     0.345381,     0.350114,     0.354897,...
    0.359729,     0.364611,     0.369544,     0.374529,     0.379565,...
    0.384653,     0.389794,     0.394989,     0.400236,     0.405538,...
    0.410894,     0.416306,     0.421773,     0.427297,     0.432877,...
    0.438514,     0.444209,     0.449962,     0.455774,     0.461645,...
    0.467577,     0.473569,     0.479621,     0.485736,     0.491912,...
    0.498151,     0.504454,     0.510819,     0.517250,     0.523745,...
    0.530308,     0.536934,     0.543629,     0.550390,     0.557220,...
    0.564119,     0.571085,     0.578125,     0.585232
    ];

width_of_band_hz_16k = [
    15.734426,     31.799433,     32.244064,     32.693359,     ...
    33.147385,     33.606140,     34.069702,     34.538116,   ...
    35.011429,     35.489655,     35.972870,     36.461121,    ... 
    36.954407,     37.452911,     40.269653,     42.311859,   ...
    45.992554,     51.348511,     55.040527,     56.775208,    ...
    58.699402,     62.445862,     64.820923,     69.195374,   ...
    76.745667,     84.016235,     90.825684,     97.931152,   ...
    103.348877,    107.801880,    113.552246,    121.490601,  ...
    130.420410,    143.431763,    158.486816,    176.872803,  ...
    198.314697,    219.549561,    240.600098,    268.702393,  ...
    306.060059,    349.937012,    398.686279,    454.713867,  ...
    506.841797,    564.863770,    637.261230,    794.717285,  ...
    931.068359
    ];

pow_dens_correction_factor_16k = [
    100.000000,     99.999992,     100.000000,    100.000008,...
    100.000008,     100.000015,    99.999992,     99.999969,  ...
    50.000027,      100.000000,    99.999969,     100.000015, ...
    99.999947,      100.000061,    53.047077,     110.000046, ...
    117.991989,     65.000000,     68.760147,     69.999931, ...
    71.428818,      75.000038,     76.843384,     80.968781, ...
    88.646126,      63.864388,     68.155350,     72.547775, ...
    75.584831,      58.379192,     80.950836,     64.135651, ...
    54.384785,      73.821884,     64.437073,     59.176456,     ...
    65.521278,      61.399822,     58.144047,     57.004543,     ...
    64.126297,      54.311001,     61.114979,     55.077751,     ...
    56.849335,      55.628868,     53.137054,     54.985844,    ...
    79.546974
    ];

abs_thresh_power_16k = [
    51286152.00,  2454709.500,  70794.593750,  ...
    4897.788574,  1174.897705,  389.045166,     ...
    104.712860,   45.708820,    17.782795,    ...
    9.772372,     4.897789,     3.090296,   ...
    1.905461,     1.258925,     0.977237,     ...
    0.724436,     0.562341,     0.457088,     ...
    0.389045,     0.331131,     0.295121,     ...
    0.269153,     0.257040,     0.251189,    ...
    0.251189,     0.251189,     0.251189,    ...
    0.263027,     0.288403,     0.309030,     ...
    0.338844,     0.371535,     0.398107,    ...
    0.436516,     0.467735,     0.489779,    ...
    0.501187,     0.501187,     0.512861,    ...
    0.524807,     0.524807,     0.524807,    ...
    0.512861,     0.478630,     0.426580,    ...
    0.371535,     0.363078,     0.416869,    ...
    0.537032
    ];

if (sampling_rate== fs_16k)
    Downsample = Downsample_16k;
    InIIR_Hsos = InIIR_Hsos_16k;
    InIIR_Nsos = InIIR_Nsos_16k;
    Align_Nfft = Align_Nfft_16k;
    Fs= fs_16k;
    
    Nb = 49;
    Sl = Sl_16k;
    Sp = Sp_16k;
    nr_of_hz_bands_per_bark_band = nr_of_hz_bands_per_bark_band_16k;
    centre_of_band_bark = centre_of_band_bark_16k;
    centre_of_band_hz = centre_of_band_hz_16k;
    width_of_band_bark = width_of_band_bark_16k;
    width_of_band_hz = width_of_band_hz_16k;
    pow_dens_correction_factor = pow_dens_correction_factor_16k;
    abs_thresh_power = abs_thresh_power_16k;
    
    return;
end

if (sampling_rate== fs_8k)
    Downsample = Downsample_8k;
    InIIR_Hsos = InIIR_Hsos_8k;
    InIIR_Nsos = InIIR_Nsos_8k;
    Align_Nfft = Align_Nfft_8k;
    Fs= fs_8k;
    
    Nb = 42;
    Sl = Sl_8k;
    Sp = Sp_8k;
    nr_of_hz_bands_per_bark_band = nr_of_hz_bands_per_bark_band_8k;
    centre_of_band_bark = centre_of_band_bark_8k;
    centre_of_band_hz = centre_of_band_hz_8k;
    width_of_band_bark = width_of_band_bark_8k;
    width_of_band_hz = width_of_band_hz_8k;
    pow_dens_correction_factor = pow_dens_correction_factor_8k;
    abs_thresh_power = abs_thresh_power_8k;
    return;
end


    
    
    